package cn.lic.tool.poi.excel.function.impl;

import org.apache.poi.ss.usermodel.Cell;

import com.alibaba.fastjson.JSONObject;

import cn.lic.tool.poi.excel.ParserUtils;
import cn.lic.tool.poi.excel.function.AbstractFunction;
import cn.lic.tool.poi.excel.function.IFunction;
import cn.lic.tool.poi.excel.function.IFunctionArgument;
import cn.lic.tool.poi.excel.function.IValue;
import cn.lic.tool.poi.excel.function.Range;
import cn.lic.tool.poi.excel.function.IValue.Type;

public class VAR extends AbstractFunction {
	
	public VAR(){}
	
	public VAR(IFunctionArgument[] args) {
		 this.args = args;
	}
	
	@Override
	public IFunction build(IFunctionArgument[] args) {
		return new VAR(args);
	}

	@Override
	public IValue execute(JSONObject ctx) {
		Object arg0 = this.getArg(0, ctx).castValue(Type.OBJECT);
		return IValue.buildSValue(arg0);
	}

	@Override
	public Range execute(JSONObject ctx, Cell cell) {
		IValue rs = this.execute(ctx);
		ParserUtils.setCellValue(cell, rs);
		return null;
	}
}
